﻿using UnityEngine;
using System.Runtime.InteropServices;
using System.Net;
using Unity.Jobs;

public class TestObjectC : MonoBehaviour
{
    
#if UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_IPHONE || UNITY_EDITOR_OSX
    private void Start()
    {
        Debug.LogError("_MacSDKSetCallBack");
        _MacSDKSetCallBack(UnityMethodCalledFromXcode);

        _MacSDKFunc1("someThing 1", UnityMethodCalledFromXcode);
        _MacSDKFunc2("someThing 2");


        Debug.LogError("test 1");

        
    }


    ////////------------------  回调方法    ------------------
    //回调方法
    /// <summary>
    /// 用来接收SDK的回调信息
    /// </summary>
    /// <param name="strType">回调类型</param>
    /// <param name="strData">回调内容</param>
    public delegate void callBackMacSDK(string strType, string strData);
    [AOT.MonoPInvokeCallback(typeof(callBackMacSDK))]
    static void UnityMethodCalledFromXcode(string strType, string strData)
     {
         Debug.Log(strType);
         Debug.Log(strData);
     }

    

#if (UNITY_IPHONE || UNITY_IOS) && !UNITY_EDITOR
    const string dllName = "__Internal";
#else
    const string dllName = "ObjectC_SDK";
#endif

    ////////------------------  和Mac SDK 的交互接口  ------------------
    // mac SDK 的接口

    
 
     [DllImport(dllName)]
     private static extern void _MacSDKSetCallBack(callBackMacSDK UnityMethodCalledFromXcode);
 
     [DllImport(dllName)]
     private static extern void _MacSDKFunc1(string someThing, callBackMacSDK UnityMethodCalledFromXcode);
 
     [DllImport(dllName)]
     private static extern void _MacSDKFunc2(string someThing);

#else
    void Start()
    {
        
    }
     
#endif
}